#include <stdint.h>
#include <stdlib.h>
#include <assert.h>
#include "gdst_array.h"
#include "view.h"


view_p view_new(uint32_t id)
{
	view_p self;
	self = malloc(sizeof(view_t));
	if (!self)
		return NULL;
	self->mems = gdst_arraynew(1, sizeof(uint32_t));
	if (!self->mems) {
		free(self);
		return NULL;
	}
	self->seqno = 0;
	self->vid = id;
	return self;
}

void view_free(view_p *self_p)
{
	assert(self_p);
	if (self_p && *self_p)
	{
		view_p self = *self_p;
		gdst_arrayfree(&self->mems);
		free(self);
		*self_p = NULL;
	}
}

